# 导包
import jsonschema
# jsonschema形式的规则
check_rules={
    "type":"object",
    "properties":{
        "success": {"type":"boolean","const": True},
        "code":{"type":"integer","const": 10000},
        "message":{"type":"string","const":"操作成功","pattern":"^操作"},
        "money":{"type":"number","const": 6.66,"pattern":"[4-7]{2}"},
        "address":{"type":"null","const": None},
        "data":{"type":"object",
                "properties":{
                    "name":{
                        "type":"string",
                        "const":"tom",
                        "pattern":"m$"
                    }
                }
                },
        "luckyNumber":{"type":"array","const":[6,8,9]}
    },

}
# jsonschema.validate()验证
check_data={
    "success": True,
    "code": 10000,
    "message": "操作成功",
    "money": 6.66,
    "address": None,
    "data": {"name": "tom"},
    "luckyNumber": [6,8,9]
}
result=jsonschema.validate(instance=check_data,schema=check_rules)
print(result)